
/**
 * Created by Administrator on 2017/10/11.
 */
require('../../../../less/back/rent/rent_detail.less');
import $ from 'jQuery';
(function () {
    let $vue = null;
    $vue = new Vue({
        el: '.backlog-main-hook',
        data: {
            leaseType: [{id: 1, name: '系统'}],
            orderStatus  : [{id: 1, name: '主动告警'}, {id: 2, name: '人工告警'}],
            paymentFlag:[{id: 0, name: '电容故障'}, {id: 1, name: '光源故障'}, {id: 2, name: '继电器故障'}, {id: 3, name: '保险丝故障'},
                {id: 4, name: '存储芯片故障'}, {id: 5, name: '时钟芯片故障'}, {id: 6, name: '读卡模块故障'}, {id: 7, name: '内部参数配置故障'},
                {id: 8, name: '漏电报警'}, {id: 9, name: '防盗报警'}, {id: 10, name: '水浸报警'}, {id: 11, name: '电流过大报警'},
                {id: 12, name: '功率过大报警'}, {id: 13, name: '功率过小报警'}, {id: 14, name: '其他'}],
            key:[{id:1,name:'告警编号'},{id:2,name:'单灯编号'},{id:3,name:'工单编号'}],
            boxs: {
                box1: {show: true, hook: '.box1-hook', lock: true, url: '', params: {}},
                box2: {show: false, hook: '.box2-hook', url: '', params: {}},
                box3: {show: false, hook: '.box3-hook', url: '', params: {}},
                box4: {show: false, hook: '.box4-hook', url: '', params: {}}
            },
        },
        created: function () {
        },
        computed:{
        },
        methods: {
            emitPage: function () {
                M.Page.load(this.boxs);
            },
            // 上一页
            prePage: function () {
                M.Page.prePage(this.boxs);
            },
            cancleBack: function () {
                M.Page.emitPrePage();
            }
        },
        mounted: function () {
            this.$nextTick(() => {
                //待签收列表
                var $rentalBox = $('.rental-hook');
                let tableHookName1 = '.relet-acord-table-hook';
                var $form = $rentalBox.find('.form-search-hook');
                $rentalBox.find('.search-hook').on('click', function () {
                    $(tableHookName1).bootstrapTable('onCustomSearch');
                });
                $('.search-hook').on('click', function () {
                    $(tableHookName1).bootstrapTable('onCustomSearch');
                });
                var $tableHook = $rentalBox.find(tableHookName1).bootstrapTable({
                    scrollbar: 'relet-acord-table-body',
                    striped: true, // 设置为 true 会有隔行变色效果
                    pagination: true, // true 显示分页
                    paginationDetail: false, // 分页详情
                    sidePagination: 'server', // 服务器端
                    method: 'post',
                    url: URI.WORKORDER.ORDER.LIST,
                    debug: false,
                    cache: false,
                    pageNumber: 1,
                    pageSize: 20,
                    // fixedColumns: true,
                    customButton: '',
                    customQueryParams: function (params) {
                        var formParams={
                            gender:"1"
                        };
                        var queryParams = $.extend({}, params, formParams);
                        return queryParams;
                    },
                    onLoadSuccess: function (data) {
                    },
                    onLoadError: function (status, xhr) {
                    },
                    onClickRow: function (row) {
                    },
                    columns: [
                      /*  {
                            field: 'no', title: '序号', align: 'center', width: 50,tips: true,
                            formatter: function (value, row, index) {
                                var pageSize = $rentalBox.find(tableHookName1).bootstrapTable('getOptions').pageSize;     //通过table的#id 得到每页多少条
                                var pageNumber = $rentalBox.find(tableHookName1).bootstrapTable('getOptions').pageNumber; //通过table的#id 得到当前第几页
                                return pageSize * (pageNumber - 1) + index + 1;    // 返回每条的序号： 每页条数 *（当前页 - 1 ）+ 序号
                            }
                        },*/
                        {
                            field: 'mobile', title: '工单编号', align: 'center', fixedLeft: true,tips:true,width:140
                        },
                        {
                            field: 'userName', title: '单灯编号', align: 'center', fixedLeft: true,width:100,
                        },
                        {
                            field: 'gender', title: '来源', align: 'center', fixedLeft: true,width:80,
                        },
                        {
                            field: 'email', title: '故障类型', align: 'center', fixedLeft: true,tips: true,
                            formatter: function (value, row, index) {
                                return '￥'+value;
                            }
                        },
                        {
                            field: 'email', title: '当前状态', align: 'center', tips:true,fixedLeft: true
                        },
                        {
                            field: 'registerTime', title: '告警时间', align: 'center', tips:true,fixedLeft: true,
                            formatter: function (value, row, index) {
                                return new Date(value).Format('yyyy-MM-dd hh:mm:ss');
                            }
                        },
                        {
                            field: 'email', title: '告警编号', align: 'center', tips:true,fixedLeft: true
                        },
                        {
                            field: 'operate', title: '操作', align: 'center', fixedLeft: true,width: 180,
                            events: {
                                'click .detail-order': function (e, value, rowData, index) {
                                    M.Page.emit(URI.WORKORDER.ORDER.DETAIL.PAGE);
                                    IOT.setSessionStore(URI.WORKORDER.ORDER.DETAIL.PAGE, JSON.stringify(rowData));
                                    return false;
                                },
                                'click .sign-order': function (e, value, rowData, index) {
                                    M.Page.emit(URI.WORKORDER.ORDER.DETAIL.PAGE);
                                    IOT.setSessionStore(URI.WORKORDER.ORDER.DETAIL.PAGE, JSON.stringify(rowData));
                                    return false;
                                }
                            },
                            formatter: function (value, row, index) {
                                let html = [];
                                if (M.Authority.checkAuthority('account-detail')) {
                                    html.push('<a class="detail-order operate">详细</a>');
                                }
                                if (M.Authority.checkAuthority('account-modify')) {
                                    html.push('<a class="sign-order operate">签收</a>');
                                }
                                return html.join('');
                            }
                        }
                    ]
                });
                //待处理列表
                var $returnBox = $('.return-hook');
                let tableHookName2 = '.return-table-hook';
                var $form = $returnBox.find('.form-search-hook');
                // 查询
                $returnBox.find('.search-hook').on('click', function () {
                    $(tableHookName2).bootstrapTable('onCustomSearch');
                });
                $('.search-hook').on('click', function () {
                    $(tableHookName2).bootstrapTable('onCustomSearch');
                });
                var $tableHook = $returnBox.find(tableHookName2).bootstrapTable({
                    scrollbar: 'return-table-body',
                    striped: true, // 设置为 true 会有隔行变色效果
                    pagination: true, // true 显示分页
                    paginationDetail: false, // 分页详情
                    sidePagination: 'server', // 服务器端
                    method: 'post',
                    url: URI.WORKORDER.ORDER.LIST,
                    debug: false,
                    cache: false,
                    pageNumber: 1,
                    pageSize: 20,
                    // fixedColumns: true,
                    customButton: '',
                    customQueryParams: function (params) {
                        /*  var formParams = $form.serializeJson();*/
                        var formParams={
                            gender:'2'
                        };
                        var queryParams = $.extend({}, params, formParams);
                        return queryParams;
                    },
                    onLoadSuccess: function (data) {
                        /* console.log(data);*/
                    },
                    onLoadError: function (status, xhr) {
                    },
                    onClickRow: function (row) {
                    },
                    columns: [
                        /*{
                            field: 'no', title: '序号', align: 'center', width: 50,tips: true,
                            formatter: function (value, row, index) {
                                var pageSize =  $returnBox.find(tableHookName2).bootstrapTable('getOptions').pageSize;     //通过table的#id 得到每页多少条
                                var pageNumber = $returnBox.find(tableHookName2).bootstrapTable('getOptions').pageNumber; //通过table的#id 得到当前第几页
                                return pageSize * (pageNumber - 1) + index + 1;    // 返回每条的序号： 每页条数 *（当前页 - 1 ）+ 序号
                            }
                        },*/
                        {
                            field: 'mobile', title: '工单编号', align: 'center', fixedLeft: true,tips:true,width:140
                        },
                        {
                            field: 'userName', title: '单灯编号', align: 'center', fixedLeft: true,width:100,
                        },
                        {
                            field: 'gender', title: '来源', align: 'center', fixedLeft: true,width:80,
                        },
                        {
                            field: 'email', title: '故障类型', align: 'center', fixedLeft: true,tips: true,
                            formatter: function (value, row, index) {
                                return '￥'+value;
                            }
                        },
                        {
                            field: 'email', title: '当前状态', align: 'center', tips:true,fixedLeft: true
                        },
                        {
                            field: 'registerTime', title: '告警时间', align: 'center', tips:true,fixedLeft: true,
                            formatter: function (value, row, index) {
                                return new Date(value).Format('yyyy-MM-dd hh:mm:ss');
                            }
                        },
                        {
                            field: 'email', title: '告警编号', align: 'center', tips:true,fixedLeft: true
                        },
                        {
                            field: 'operate', title: '操作', align: 'center', fixedLeft: true,width: 180,
                            events: {
                                'click .detail-order': function (e, value, rowData, index) {
                                    M.Page.emit(URI.WORKORDER.ORDER.DETAIL.PAGE);
                                    IOT.setSessionStore(URI.WORKORDER.ORDER.DETAIL.PAGE, JSON.stringify(rowData));
                                    return false;
                                },
                                'click .dispose-order': function (e, value, row, index) {
                                    M.Page.emit(URI.WORKORDER.ORDER.DETAIL.PAGE);
                                    IOT.setSessionStore(URI.WORKORDER.ORDER.DETAIL.PAGE, JSON.stringify(rowData));
                                    return false;
                                },
                            },
                            formatter: function (value, row, index) {
                                let html = [];
                                if (M.Authority.checkAuthority('account-detail')) {
                                    html.push('<a class="detail-order operate">详细</a>');
                                }
                                if (M.Authority.checkAuthority('account-delete')) {
                                    html.push('<a class="dispose-order operate">处理</a>');
                                }
                                return html.join('');
                            }
                        }
                    ]
                });
                //待审核列表
                var $subletBox = $('.sublet-hook');
                let tableHookName3 = '.sublet-table-hook';
                var $form = $subletBox.find('.form-search-hook');
                // 查询
                $subletBox.find('.search-hook').on('click', function () {
                    $(tableHookName3).bootstrapTable('onCustomSearch');
                });
                $('.search-hook').on('click', function () {
                    $(tableHookName3).bootstrapTable('onCustomSearch');
                });
                var $tableHook = $subletBox.find(tableHookName3).bootstrapTable({
                    scrollbar: 'sublet-table-body',
                    striped: true, // 设置为 true 会有隔行变色效果
                    pagination: true, // true 显示分页
                    paginationDetail: false, // 分页详情
                    sidePagination: 'server', // 服务器端
                    method: 'post',
                    url: URI.WORKORDER.ORDER.LIST,
                    debug: false,
                    cache: false,
                    pageNumber: 1,
                    pageSize: 20,
                    // fixedColumns: true,
                    customButton: '',
                    customQueryParams: function (params) {
                        /*  var formParams = $form.serializeJson();*/
                        var formParams={
                            gender:'0'
                        }
                        var queryParams = $.extend({}, params, formParams);
                        return queryParams;
                    },
                    onLoadSuccess: function (data) {
                    },
                    onLoadError: function (status, xhr) {
                    },
                    onClickRow: function (row) {
                    },
                    columns: [
                      /*  {
                            field: 'no', title: '序号', align: 'center', width: 50,
                            formatter: function (value, row, index) {
                                var pageSize =  $subletBox.find(tableHookName3).bootstrapTable('getOptions').pageSize;     //通过table的#id 得到每页多少条
                                var pageNumber = $subletBox.find(tableHookName3).bootstrapTable('getOptions').pageNumber; //通过table的#id 得到当前第几页
                                return pageSize * (pageNumber - 1) + index + 1;    // 返回每条的序号： 每页条数 *（当前页 - 1 ）+ 序号
                            }
                        },*/
                        {
                            field: 'mobile', title: '工单编号', align: 'center', fixedLeft: true,tips:true,width:140
                        },
                        {
                            field: 'userName', title: '单灯编号', align: 'center', fixedLeft: true,width:100,
                        },
                        {
                            field: 'gender', title: '来源', align: 'center', fixedLeft: true,width:80,
                        },
                        {
                            field: 'email', title: '故障类型', align: 'center', fixedLeft: true,tips: true,
                            formatter: function (value, row, index) {
                                return '￥'+value;
                            }
                        },
                        {
                            field: 'email', title: '当前状态', align: 'center', tips:true,fixedLeft: true
                        },
                        {
                            field: 'registerTime', title: '告警时间', align: 'center', tips:true,fixedLeft: true,
                            formatter: function (value, row, index) {
                                return new Date(value).Format('yyyy-MM-dd hh:mm:ss');
                            }
                        },
                        {
                            field: 'email', title: '告警编号', align: 'center', tips:true,fixedLeft: true
                        },
                        {
                            field: 'operate', title: '操作', align: 'center', fixedLeft: true,width: 180,
                            events: {
                                'click .detail-order': function (e, value, rowData, index) {
                                    M.Page.emit(URI.WORKORDER.ORDER.DETAIL.PAGE);
                                    IOT.setSessionStore(URI.WORKORDER.ORDER.DETAIL.PAGE, JSON.stringify(rowData));
                                    return false;
                                },
                                'click .audit-order': function (e, value, rowData, index) {
                                    M.Page.emit(URI.WORKORDER.ORDER.DETAIL.PAGE);
                                    IOT.setSessionStore(URI.WORKORDER.ORDER.DETAIL.PAGE, JSON.stringify(rowData));
                                    return false;
                                }
                            },
                            formatter: function (value, row, index) {
                                let html = [];
                                if (M.Authority.checkAuthority('account-detail')) {
                                    html.push('<a class="detail-order operate">详细</a>');
                                }
                                if (M.Authority.checkAuthority('account-modify')) {
                                    html.push('<a class="audit-order operate">审核</a>');
                                }
                                return html.join('');
                            }
                        }
                    ]
                });
            })}
    });

    $('.change_box .change_point').click(function(){
        $('.change_btn .change_box').removeClass('change_active');
        $(this).parent().addClass('change_active');
        $('ul.detail_contain.accord').hide();
        $('ul.detail_contain.accord').eq($(this).index()).show();
        $('.table_contain').removeClass('show');
        $('.table_contain').eq($(this).parent().index()).addClass('show');
        $('.table_contain').eq($(this).parent().index()).find('tbody tr:first td').trigger("click");
        if( $('.table_contain').eq($(this).parent().index()).find('tbody tr:first td').length ==1){
            $vue.$data.rental ={};
        }
    })
})();




















